package com.tanglongan.concurrent._basic;

public class Demo19 {
    public static void main(String[] args) throws InterruptedException {
        Demo19Service service = new Demo19Service();

        Thread t1 = new Thread(service::printString);
        t1.setName("A");
        t1.start();

        Thread.sleep(10);

        Thread t2 = new Thread(service::printString);
        t2.start();
    }
}

class Demo19Service {
    synchronized public void printString() {
        System.out.println("线程开始");
        if ("A".equals(Thread.currentThread().getName())) {
            System.out.println("A线程永远suspend了");
            Thread.currentThread().suspend();
        }
        System.out.println("线程结束");
    }
}